﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class MasterPage : System.Web.UI.MasterPage
{
    protected string myUrl = @""+clsPublic.myURL();
    protected string myUsername = "";
    protected string myRoleText = "";
    protected bool seeBienlai = false;
    protected string headerTBDP_text = "";
    protected string headerTBDP_href = "";
    protected string headerTBDP_title = "";

    protected string headerBLTP_text = "";
    protected string headerBLTP_href = "";
    protected string headerBLTP_title = "";

    protected string quanlyquyen_text = "";
    protected string quanlyquyen_href = "";
    protected string quanlyquyen_title = "";
        
    protected void Page_Load(object sender, EventArgs e)
    {
        callbound();
        calllinksubsetting();
    }
    protected bool CheckSeeMenu_MasterPage(string sys_Muc_Id, int sys_F_STTQUYEN)
    {
        bool rs = false;
        HttpCookie cookie = Request.Cookies["Admin"];
        if (Session["user"] != null)
        {
            //Session["sttquyen"]
            if (Session["sttquyen"] != null)
            {
                try
                {
                    sys_F_STTQUYEN = int.Parse(Session["sttquyen"].ToString());
                    rs = cls_tbQuyen_Muc_Detail.SeeMenu(sys_Muc_Id, sys_F_STTQUYEN);
                }
                catch
                {
                    //rs = false; 
                }
            }
            else
            {
                //rs = false;
            }
        }
        else
        {
            //rs = false;
        }
        return rs;
    }
    protected void calllinksubsetting()
    {
        headerTBDP_text = "Header thông báo đóng...";
        headerTBDP_href = "" + myUrl + "quan-ly-header-report-thong-bao-dong-phi.html";
        headerTBDP_title = "Header thông báo đóng phí";

        headerBLTP_text = "Header biên lai thu phí";
        headerBLTP_href = "" + myUrl + "quan-ly-header-report-bien-lai.html";
        headerBLTP_title = "Header biên lai thu phí";

        quanlyquyen_text = "Quản lý quyền";
        quanlyquyen_href = "" + myUrl + "quan-ly-quyen.html";
        quanlyquyen_title = "Quản lý quyền";
                

        if (Session["sttquyen"] != null && int.Parse(Session["sttquyen"].ToString()) != 100)
        {
            if (Session["sttquyen"].ToString() == "1")
            {

            }
            else
            {
                headerTBDP_href = "#";
                headerBLTP_href = "#";
                quanlyquyen_href = "#";
            }
        }
        else
        { 
            
        }
    }
    protected void callbound()
    {
        HttpCookie cookie = Request.Cookies["Admin"];
        if (Session["user"] != null)
        {
            lbluser.Text = Session["user"].ToString();
            myUsername = lbluser.Text;
            string user = (lbluser.Text);
            DataTable dt = cls_tbNHANVIEN.GetByUser(user);
            if (dt.Rows.Count > 0)
            {
                //if (dt.Rows[0]["Limit"].ToString() != "1")
                //{
                //    full.Visible = false;
                //    decentralization.Visible = true;
                //}
                myUsername += " - " + dt.Rows[0][1].ToString() + " ";//F_HOTENNV
                //cls_tbQUYEN.quyen = dt.Rows[0][5].ToString();
            }
        }
        else
        {
            Response.Redirect(myUrl + "dang-nhap.html");
        }
        //myRoleText
        if (Session["sttquyen"] != null)
        {
            int mysttquyen = -1;
            try
            {
                mysttquyen = int.Parse(Session["sttquyen"].ToString());
            }
            catch { }
            myRoleText = cls_tbQUYEN.GetF_TENQUYEN(mysttquyen);
        }

        string HOTEN = tb_hovaten.Text.Trim();
        string DIENTHOAI = tb_dienthoai.Text.Trim();
        if (HOTEN != string.Empty || DIENTHOAI != string.Empty)
        {
            gv_result_search.DataSource = cls_tbHOCVIEN.Search(HOTEN, DIENTHOAI);
            gv_result_search.DataBind();
        }
        try
        {
            if (Session["sttquyen"] != null && int.Parse(Session["sttquyen"].ToString()) != 100)
            {
                seeBienlai = false;
            }
            else
            {
                seeBienlai = true;
            }
        }
        catch { }
        try
        {
            //tam thoi khoa bang code tay
            if (Session["sttquyen"].ToString() == "5")
            {
                //TQM00.Visible = true;
                //TQM01.Visible = true;
                //TQM02.Visible = true;
                //TQM03.Visible = true;
                //TQM04.Visible = true;
                //TQM05.Visible = true;
                //TQM06.Visible = false;
                //TQM07.Visible = false;
                //TQM08.Visible = false;
                //TQM09.Visible = false;
                //TQM0A.Visible = false;
                //TQM0B.Visible = false;
                //TQM0C.Visible = false;
                //TQM0D.Visible = false;
                //TQM0E.Visible = false;
                //TQM0F.Visible = false;
                //TQM10.Visible = false;
                //TQM11.Visible = false;
                ////TQM12.Visible = true;
                //TQM13.Visible = false;
                //TQM14.Visible = true;
                //TQM15.Visible = true;
                //TQM16.Visible = true;
                //TQM17.Visible = true;
                //TQM18.Visible = true;
                //TQM19.Visible = false;
                //TQM1A.Visible = false;
                //TQM1B.Visible = false;                
            }
            else
            {

            }
            TQM00.Visible = CheckSeeMenu_MasterPage("00", -1);
            TQM01.Visible = CheckSeeMenu_MasterPage("01", -1);
            TQM02.Visible = CheckSeeMenu_MasterPage("02", -1);
            TQM03.Visible = CheckSeeMenu_MasterPage("03", -1);
            TQM04.Visible = CheckSeeMenu_MasterPage("04", -1);
            TQM05.Visible = CheckSeeMenu_MasterPage("05", -1);
            TQM06.Visible = CheckSeeMenu_MasterPage("06", -1);
            TQM07.Visible = CheckSeeMenu_MasterPage("07", -1);
            TQM08.Visible = CheckSeeMenu_MasterPage("08", -1);
            TQM09.Visible = CheckSeeMenu_MasterPage("09", -1);
            TQM0A.Visible = CheckSeeMenu_MasterPage("0A", -1);
            TQM0B.Visible = CheckSeeMenu_MasterPage("0B", -1);
            TQM0C.Visible = CheckSeeMenu_MasterPage("0C", -1);
            TQM0D.Visible = CheckSeeMenu_MasterPage("0D", -1);
            TQM0E.Visible = CheckSeeMenu_MasterPage("0E", -1);
            TQM0F.Visible = CheckSeeMenu_MasterPage("0F", -1);
            TQM10.Visible = CheckSeeMenu_MasterPage("10", -1);
            TQM11.Visible = CheckSeeMenu_MasterPage("11", -1);
            //TQM12.Visible = CheckSeeMenu_MasterPage("12", -1);
            TQM13.Visible = CheckSeeMenu_MasterPage("13", -1);
            TQM14.Visible = CheckSeeMenu_MasterPage("14", -1);
            TQM15.Visible = CheckSeeMenu_MasterPage("15", -1);
            TQM16.Visible = CheckSeeMenu_MasterPage("16", -1);
            TQM17.Visible = CheckSeeMenu_MasterPage("17", -1);
            TQM18.Visible = CheckSeeMenu_MasterPage("18", -1);
            TQM19.Visible = CheckSeeMenu_MasterPage("19", -1);
            TQM1A.Visible = CheckSeeMenu_MasterPage("1A", -1);
            TQM1B.Visible = CheckSeeMenu_MasterPage("1B", -1);
            TQM1C.Visible = CheckSeeMenu_MasterPage("1C", -1);
        }
        catch { } 
    }
    protected void btn_timkiem_hocvien_Click(object sender, EventArgs e)
    {
        //ASPxPopup_ketqua_timkiem_hocvien.ShowOnPageLoad = true;
    }    
}
